package com.dxs.Controller;


import com.dxs.Entity.EntityUser;
import com.dxs.Entity.EntityUserData;
import com.dxs.Entity.FireDataEntity;
import com.dxs.enums.ResponseCode;
import lombok.Data;

import java.util.List;

@Data
public class ResultBean<T> {

    private int code;
    private String msg;
    private T data;

    public static ResultBean<String> Error(String msg){
        ResultBean<String> resultBean = new ResultBean<>();
        resultBean.setCode(ResponseCode.ERROR.getCode());
        resultBean.setMsg(msg);
        return resultBean;
    }
    public static ResultBean<String> Success(String msg){
        ResultBean<String> resultBean = new ResultBean<>();
        resultBean.setCode(ResponseCode.SUCCESS.getCode());
        resultBean.setMsg(msg);
        return resultBean;
    }

    public ResultBean<T> Success2(String msg ,T data){
        ResultBean<T> resultBean = new ResultBean<>();
        resultBean.setCode(ResponseCode.SUCCESS.getCode());
        resultBean.setMsg(msg);
        resultBean.setData(data);
        return resultBean;
    }

    public static ResultBean<EntityUser> loginSuccess(String msg, EntityUser user){
        ResultBean<EntityUser> resultBean = new ResultBean<>();
        resultBean.setCode(ResponseCode.SUCCESS.getCode());
        resultBean.setMsg(msg);
        resultBean.setData(user);
        return resultBean;
    }

    public static ResultBean<String> uploadSuccess(String msg, String fileUrl){
        ResultBean<String> resultBean = new ResultBean<>();
        resultBean.setCode(ResponseCode.SUCCESS.getCode());
        resultBean.setMsg(msg);
        resultBean.setData(fileUrl);
        return resultBean;
    }

    public static ResultBean<String> uploadError(String msg, String fileUrl){
        ResultBean<String> resultBean = new ResultBean<>();
        resultBean.setCode(ResponseCode.ERROR.getCode());
        resultBean.setMsg(msg);
        resultBean.setData(fileUrl);
        return resultBean;
    }
    public static ResultBean<List<EntityUserData>> getDataListSuccess(String msg, List<EntityUserData> list){
        ResultBean<List<EntityUserData>> resultBean = new ResultBean<>();
        resultBean.setCode(ResponseCode.SUCCESS.getCode());
        resultBean.setMsg(msg);
        resultBean.setData(list);
        return resultBean;
    }

    public static ResultBean<List<FireDataEntity>> getFireDataListSuccess(String msg, List<FireDataEntity> list){
        ResultBean<List<FireDataEntity>> resultBean = new ResultBean<>();
        resultBean.setCode(ResponseCode.SUCCESS.getCode());
        resultBean.setMsg(msg);
        resultBean.setData(list);
        return resultBean;
    }

    public static ResultBean<EntityUserData> getDataSuccess(String msg, EntityUserData userData){
        ResultBean<EntityUserData> resultBean = new ResultBean<>();
        resultBean.setCode(ResponseCode.SUCCESS.getCode());
        resultBean.setMsg(msg);
        resultBean.setData(userData);
        return resultBean;
    }

    public static ResultBean<FireDataEntity> getFireDataSuccess(String msg, FireDataEntity fireDataEntity){
        ResultBean<FireDataEntity> resultBean = new ResultBean<>();
        resultBean.setCode(ResponseCode.SUCCESS.getCode());
        resultBean.setMsg(msg);
        resultBean.setData(fireDataEntity);
        return resultBean;
    }
}
